<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Stacked Bar Chart</title>
    <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
</head>
<body>
    <div id="chart" style="width: 100%; height: 600px;"></div>
    <script>
        // Initialize the chart
        var chart = echarts.init(document.getElementById('chart'));

        // Specify the chart configuration
        var option = {
            title: {
                text: '不同因素对幸福水平的贡献',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            legend: {
                data: ['生活自由度', '社会支持度', '健康水平', '互助指数', 'GDP', '腐败感知度'],
                top: 30
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                data: ['Australia', 'Canada', 'Britain', 'America', 'India']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: '生活自由度',
                    type: 'bar',
                    stack: 'total',
                    data: [0.142, 0.137, 0.138, 0.121, 0.232],
                    itemStyle: {color: '#D0E3FA'}
                },
                {
                    name: '社会支持度',
                    type: 'bar',
                    stack: 'total',
                    data: [0.274, 0.274, 0.257, 0.287, 0.198],
                    itemStyle: {color: '#F8BBD0'}
                },
                {
                    name: '健康水平',
                    type: 'bar',
                    stack: 'total',
                    data: [0.13, 0.132, 0.13, 0.112, 0.126],
                    itemStyle: {color: '#FFE0B2'}
                },
                {
                    name: '互助指数',
                    type: 'bar',
                    stack: 'total',
                    data: [0.042, 0.043, 0.052, 0.046, 0.053],
                    itemStyle: {color: '#FFCC80'}
                },
                {
                    name: 'GDP',
                    type: 'bar',
                    stack: 'total',
                    data: [0.349, 0.345, 0.354, 0.4, 0.353],
                    itemStyle: {color: '#C8E6C9'}
                },
                {
                    name: '腐败感知度',
                    type: 'bar',
                    stack: 'total',
                    data: [0.061, 0.069, 0.068, 0.035, 0.037],
                    itemStyle: {color: '#FFAB91'}
                }
            ]
        };

        chart.setOption(option);
    </script>
</body>
</html>
